package com.itheima.test6;

public class Test {
    public static void main(String[] args) {
        //通过匿名内部类实现
        goSwimming(new Swimming() {
            @Override
            public void swim() {
                System.out.println("去游泳");
            }
        });
//        通过Lambda表达式实现
//        理解:对于Lambda表达式，对匿名内部类进行了优化
        goSwimming(() -> System.out.println("去游泳"));
    }

    public static void goSwimming(Swimming swimming){
        swimming.swim();
       /* Swimming swimming1 = new Swimming() {
            @Override
            public void swim() {
                System.out.println("去游泳");
            }
        };*/
    }
}

interface Swimming{
    void swim();
}
